<template>
	<view class="message" >
				<u-cell v-for="(item, index) in messageList" :key="index" @click="goMessageDetails(item)">
					<view class="title" slot="title">{{item.title}}</view>
					<view class="label" slot="label">
						<span class="read">阅读量：{{item.read}}</span>
						<span class="time">{{initDate(item.push_time)}}</span>
					</view>
				</u-cell>
	</view>
</template>

<script>
	export default {
		props: {
			messageList: {
				type: Array,
				default: []
			}
		},
		onHide() {
			this.messageList = []
		},
		methods: {
			initDate(timestamp) {
				var date = new Date(timestamp * 1000); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
				const Y = date.getFullYear() + '-';
				const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
				const D = date.getDate() + ' ';
				const h = date.getHours() + ':';
				const m = date.getMinutes() + ':';
				const s = date.getSeconds();
				return Y + M + D + h + m + s;
			},
			// 获取帮助中心详情
			goMessageDetails(val) {
				console.log("555555555555555");
				uni.navigateTo({
					url: "/subpages/messageDetails/messageDetails?id=" + val.id
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.message{
		min-height: 100vh;
	}
	.title {
		margin: 5rpx 0 10rpx 0;
		height: 80rpx;
		line-height: 80rpx;
		font-size: 30rpx;
		font-weight: 700;
		width: 100%;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.label {
		display: flex;
		justify-content: space-between;
		color: #969799;
		font-size: 25rpx;
	}
</style>
